package base_demo.printNumber;

public class MyThread extends Thread {
    static int number = 1;

    @Override
    public void run() {
        while (true) {
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            if(number >= 100){
                break;
            }
            synchronized (MyThread.class) {
                if (number % 2 != 0) {
                    System.out.println(Thread.currentThread().getName() + "输出了奇数" + number);
                    number++;
                } else {
                    number++;
                }
            }
        }

    }
}